var map; var markers = []; var mapCenter; var latLongCheck = 0; var lowerBound; var upperBound; var skipRedraw = false; var maxResults = 50; var formFields = ['lowPrice', 'highPrice', 'bedRooms','bathRooms','daysOnMarket', 'sqFt', 'acres', 'propTypeSelect']; // Will hold MarkerClusterer object var mc = null; // MarkerClusterer Options var mcOptions = mcOptions = { averageCenter : true, gridSize : 50, maxZoom : 15//, // There are 5 levels (sizes) for clusters available. You can set styling for each one. // The 'url' parameter links to cluster icon - you can link an empty image here and style the clusters with CSS // Notice 'width' and 'height' parameters - these are important for setting cluster sizes. /** styles : [{ 'textColor' : 'white', 'width' : 36, 'height' : 36, 'url' : 'https://example.com/images/map-marker-1.png', 'textSize' : 13, 'fontFamily': '"Helvetica Neue", Helvetica, Arial, sans-serif' }, { 'textColor' : 'white', 'width' : 40, 'height' : 40, 'url' : 'https://example.com/images/map-marker-2.png', 'textSize' : 13, 'fontFamily': '"Helvetica Neue", Helvetica, Arial, sans-serif' }, { 'textColor' : 'white', 'width' : 44, 'height' : 44, 'url' : 'https://example.com/images/map-marker-3.png', 'textSize' : 13, 'fontFamily': '"Helvetica Neue", Helvetica, Arial, sans-serif' }, { 'textColor' : 'white', 'width' : 48, 'height' : 48, 'url' : 'https://example.com/images/map-marker-4.png', 'textSize' : 13, 'fontFamily': '"Helvetica Neue", Helvetica, Arial, sans-serif' }, { 'textColor' : 'white', 'width' : 52, 'height' : 52, 'url' : 'https://example.com/images/map-marker-5.png', 'textSize' : 13, 'fontFamily': '"Helvetica Neue", Helvetica, Arial, sans-serif' } ] */ }; function gatherSearch(){ var params = ''; for (var i = 0; i < formFields.length; i++) { if (fieldExists($(formFields[i]))) { var fieldValue = $(formFields[i]).value; var fieldName = $(formFields[i]).name; if (fieldValue != '' && fieldValue != null) params = params+'&'+fieldName+'='+fieldValue; } } return params; } function googleLoad() { map = new google.maps.Map( document.getElementById('IDX-mapContainer'), { center: new google.maps.LatLng(45.9833463, -87.204476 ), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }); map.enableKeyDragZoom({ visualEnabled: true, maxZoom : 18, visualPosition: google.maps.ControlPosition.LEFT, visualPositionOffset: new google.maps.Size(13, 0), visualPositionIndex: null, visualSprite: "https://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png", visualSize: new google.maps.Size(20, 20), visualTips: { off: "Turn on", on: "Turn off" } }); google.maps.event.addListener(map, "click", function (event) { var latitude = event.latLng.lat(); var longitude = event.latLng.lng(); //alert(latitude+":"+longitude); }); //end addListener google.maps.event.addListener(map, "maptypechanged", function () { skipRedraw = true; }); google.maps.event.addListener(map, "moveend", function() { console.log( 'Moveend' ); if (skipRedraw == false) { var bounds = map.getBounds(); lowerBound = bounds.getSouthWest(); upperBound = bounds.getNorthEast(); loadPins(); } else skipRedraw = false; }); google.maps.event.addListener(map, "bounds_changed", function() { if (skipRedraw == false) { var bounds = map.getBounds(); lowerBound = bounds.getSouthWest(); upperBound = bounds.getNorthEast(); //loadPins(); pausedUpdate(); } else skipRedraw = false; }); google.maps.event.addListener(map, "infowindowopen", function() { var existingSwBounds = boundToCSV(lowerBound); var existingNeBounds = boundToCSV(upperBound); var bounds = map.getBounds(); var newSwBounds = boundToCSV(bounds.getSouthWest()); var newNeBounds = boundToCSV(bounds.getNorthEast()); if (existingSwBounds != newSwBounds || existingNeBounds != newNeBounds) skipRedraw = true; map.savePosition(); }); } function loadPins() { // Call setStatusLoading function that add a loader animation setStatusLoading(); // Calling our new 'clearMarkers' function which will also clear MarkerClusterer markers clearMarkers(); google.maps.event.addListener(map, 'bounds_changed', function() { var bounds = map.getBounds(); var upperBound = bounds.getNorthEast(); var lowerBound = bounds.getSouthWest(); }); latLongCheck = lowerBound; var url = '../idx/loadMapStart.php'; var currentZoom = map.getZoom(); param = 'stp=map&cid=14268&lb='+lowerBound+'&ub='+upperBound+'&zoom='+currentZoom+'&maxPer=50&per=100'; param = param+gatherSearch(); var myAjax = new Ajax.Request( url, { method: 'post', parameters: param, onLoading: function(origonalRequest) { if (origonalRequest.responseText.length == 0) { $('IDX-mapOverlay').innerHTML = "